package com.msh.artascope.devcloud.client.po;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.msh.artascope.interfaces.ILoginAccount;
import com.msh.frame.client.base.BasePo;
import com.msh.frame.client.validation.IInsertVo;
import com.msh.frame.client.validation.IUpdateVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;

/**
 * @author shihu
 * @mail m-sh@qq.com
 */
@Data
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Schema(name = "模块信息Po")
public class ModulePo extends BasePo{
  @NotNull(groups = {IUpdateVo.class}, message = "id不能为空")
  @Schema(name = "主键")
  private Long id;

  @NotNull(groups = {IInsertVo.class},message = "项目不能为空")
  @Schema(name = "项目")
  private Long projectId;

  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 100, message = "name长度范围最大100")
  @Schema(name = "模块名称")
  private String name;

  @NotNull(groups = {IInsertVo.class},message = "模块类型不能为空")
  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 20, message = "type长度范围最大20")
  @Schema(name = "模块类型")
  private String type;

  @NotNull(groups = {IUpdateVo.class}, message = "更新版本不能为空")
  @Schema(name = "更新版本")
  private Integer updateVersion;

  @JsonFormat(timezone = "GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
  @Schema(name = "创建时间")
  private Date createTime;

  @JsonFormat(timezone = "GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
  @Schema(name = "更新时间")
  private Date updateTime;

  @NotNull(groups = {IInsertVo.class},message = "环境id不能为空")
  @Schema(name = "环境id")
  private Long envId;

  @Schema(name = "租户")
  private Long tenantId;



  public void initLoginAccount(ILoginAccount loginAccount){
    this.tenantId = loginAccount.getTenantId();
  }
}



